package org.example.Controller;

import com.baidubce.qianfan.Qianfan;
import com.baidubce.qianfan.model.chat.ChatResponse;
import org.example.common.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("hello")
public class HelloController {
    @GetMapping("/ai")
    public Result hello(String question){
        System.out.println(question+"qu");
        Qianfan qianfan = new Qianfan("10261810c3af4533bae03979cd13cd2a" , "2785b29774354c2d86f68db63d969b56" );
        //指定模型
        ChatResponse resp = qianfan.chatCompletion()
                .model("ERNIE-4.0-8K")
                .addMessage( "user",question)
                .execute();
        System.out.println(resp.getResult());

        return Result.ok(resp.getResult());
    }
    @GetMapping("hello")
    public String hello(){
        return  "hello";
    }
}
